﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class OProjectEdit : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.修改 };
            }
        }
        protected override string DWZRef
        {
            get { return "OProjectList"; }
        }

        #region
        /// <summary>
        /// 需要修改的用户ID
        /// </summary>
        protected int PID
        {
            get
            {
                return GetRequestValue<int>("PID", 0);
            }
        }

        private OProjectInfo _obj;
        protected OProjectInfo obj
        {
            get
            {
                if (_obj == null)
                    _obj = OProjectController.GetById(PID);
                return _obj;
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                addmenu();
            }
        }

        protected void addmenu()
        {
            OProjectInfo obj2 = Request.SerializableObject<OProjectInfo>();

            //if (OUserController.CheckUserName(obj.UserName))
            //{
            //    AlertJson("登陆帐户名已存在,请重新输入.");
            //    return;
            //}
            this.AddLog(Permission.新增, obj, obj2);

            if (OProjectController.Update(obj2))
                SuccessJson("修改成功", this.DWZRef);
            else
                ErrorJson("修改失败", this.DWZRef);
        }
    }
}